import api from "@/libs/request";

/**
 * 获取店铺当前可购买套餐列表
 */
export const getMealList = (tenantId) => {
    return api.get(`/platform/shop/package/info`, {}, {
        headers: {
            tenantId,
        },
    });
};


/**
 * 用户套餐操作(续费|购买|升级)
 * @param data
 */
export const buyMeal = data => {
    return api.post(
        `/platform/sys-shop-package-order/user/buy`,
        JSON.stringify(data),
        {
            headers: {
                "Content-Type": "application/json",
            },
        },
    );
};

/**
 * 查询指定订单是否支付成功,支付成功返回date=true
 */
export const checkPayStatus = orderId => {
    return api.get(`/platform/sys-shop-package-order/${orderId}`, {});
};

// 查询收款配置
export const getPayConfig = () => {
    return api.get(`/platform/system-conf/pay/config`, {});
};

/**
 * 商户查询自己的套餐订单
 */
export const getOwnMeal = data => {
    return api.get(`/platform/sys-shop-package-order/console/order`, data);
};

/**
 * 计算套餐价格（购买/升级/消费）
 */
export const calculateMealPrice = data => {
    return api.post(
        `/platform/sys-shop-package-order/calculate/price`,
        JSON.stringify(data),
        {
            headers: {
                "Content-Type": "application/json",
            },
        },
    );
};
